#!/bin/bash
#############
#Date 2022/12/16
#mail it-arch
#############
echo "##########################################"
echo "Auto Install wordpress.                 ##"
echo "Press Ctrl + C to cancel                ##"
echo "Any key to continue                     ##"
echo "##########################################"
read -n 1
/etc/init.d/iptables status >/dev/null 2>&1
if [ $? -eq 0 ]
then
iptables -I INPUT -p tcp --dport 80 -j ACCEPT && 
iptables -I INPUT -p tcp --dport 443 -j ACCEPT &&
iptables -I INPUT -p tcp --dport 10051 -j ACCEPT &&
iptables -I INPUT -p tcp --dport 10050 -j ACCEPT &&
iptables -I INPUT -p tcp --dport 3000 -j ACCEPT &&
#iptables -I INPUT -p tcp --dport 3306 -j ACCEPT && 
iptables-save >/dev/null 2>&1
else
	echo -e "\033[32m iptables is stopd\033[0m"
fi
sed -i "s/SELINUX=enforcing/SELINUX=disabled/"  /etc/selinux/config
setenforce 0
IP=`ifconfig |grep "inet addr"|grep -v "127.0.0.1"|awk  '{print $2}'|awk -F: '{print $2}'`
yum install -y ntpdate vim zcat wget httpd mysql mysql-server mysql-devel 
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm 
yum remove php* -y
yum install php55w  php55w-bcmath php55w-cli php55w-common  php55w-devel php55w-fpm    php55w-gd php55w-imap  php55w-ldap php55w-mbstring  php55w-mysql   php55w-odbc   php55w-pdo   php55w-pear  php55w-pecl-igbinary  php55w-xml php55w-xmlrpc php55w-opcache php55w-intl php55w-pecl-memcache -y
ntpdate -s time1.aliyun.com 
echo "*/5 * * * * /usr/sbin/ntpdate -s time1.aliyun.com">>/var/spool/cron/root
service httpd start 
service mysqld start 
service php-fpm start 
chkconfig httpd on 
chkconfig mysqld on 
chkconfig php-fpm on 
mysqladmin -u root password "mysqladmin"
echo -e "\033[32m 创建数据库，导入数据 \033[0m"
mysql -uroot -pmysqladmin -e "create database wordpress character set utf8;" 
mysql -uroot -pmysqladmin -e "grant all privileges on wordpress.* to root@localhost identified by 'mysqladmin';"
mysql -uroot -pmysqladmin -e "flush privileges;"
cd /var/www/html
wget https://cn.wordpress.org/wordpress-4.7-zh_CN.tar.gz
tar -xzvf  wordpress-4.7-zh_CN.tar.gz
chown apache.root wordpress/ -R
######################################
echo -e "\033[32m wordpress is Install Success,mysql username:root  Passwd:mysqladmin \033[0m"
echo -e "\033[32m wordpress database is wordpress, URL:http://$IP/wordpress \033[0m"

